home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 July / EnigmA AMIGA RUN 09 (1996)(G.R. Edizioni)(IT)[!][issue 1996-07 & 08][EARSAN CD VIII].iso / earcd / gcc / ixml000t.lha / Sys / libs / README < prev   
Text File  |  1996-05-18  |  14KB  |  277 lines

  1. IMPORTANT
  2.  
  3. Always read the NEWS file for information about new features!
  4.  
  5. Starting with ixemul.library version 42.0 the ssystem() function is no longer
  6. supported. The only two applications use this function are (to my knowledge)
  7. gcc and man. You should either upgrade to the latest gcc (2.7.2 or higher)
  8. or replace gcc by gccv (which is part of older gcc distributions). You can
  9. find a new 'man' version on ADE.
  10.  
  11. Starting with ixemul.library version 43.1 various networking functions have
  12. been moved to libc.a. See the NEWS file for details. It only concerns
  13. certain somewhat specialized functions, so 'normal' clients and daemons
  14. shouldn't be affected.
  15.  
  16. INTRODUCTION
  17.  
  18. Originally created in 1991 or 1992 by Markus Wild, the ixemul.library has
  19. become the driving force behind the ADE project.
  20.  
  21. Essentially it is a BSD-4.3 Unix kernel running under the Amiga OS.  The
  22. code for handling Unix signals is taken almost verbatim from the BSD kernel
  23. sources, for example.  Multitasking and file I/O is, of course, passed on
  24. to the Amiga OS.  Because the library resembles BSD Unix so closely, it has
  25. made it possible to port almost all Unix programs.
  26.  
  27. However, because of the conformance to BSD, the library is not too
  28. conservative with resources or overly concerned with Amiga standards.  For
  29. example, command line expansion uses Unix semantics and doesn't use
  30. ReadArgs().  The purpose of ixemul.library is to emulate Unix as well as is
  31. technically possible.  So given a choice between Amiga behavior or Unix
  32. behavior, the last one is chosen.
  33.  
  34. HISTORY
  35.  
  36. As I mentioned, the library was originally created by Markus Wild.  It
  37. allowed him to port Unix programs, most notably gcc and a Unix shell
  38. (pdksh), which in turn gave him the opportunity to start porting NetBSD
  39. Unix.  At some point he stopped working on ixemul.library and continued
  40. with the real thing, NetBSD.
  41.  
  42. Although Markus made some snapshots of his library available on Internet,
  43. he was about the only one who could actually compile it.  The snapshots
  44. where never complete and didn't use a standard Make tool.
  45.  
  46. Rafael W.  Luebbert managed around June 1994 to actually compile the
  47. library using bits and pieces from four different source releases.  Even
  48. then he had to write some missing code and had to debug a lot before he got
  49. it working.  Luebbert released versions 40.1 through 40.4.  Since this was
  50. the only version available that could actually be compiled, Fred Fish
  51. switched to version 40.4 for his FreshFish CDROM series.
  52.  
  53. Leonard Norrgard also started working on 40.4, fixing a variety of
  54. problems.  So for a time there were two versions of the library, both
  55. derived from 40.4.  Around March 1995 I began contributing my own fixes for
  56. the library to Fred, including a fix for a horrible memory trashing bug
  57. which substantially improved the stability of the library.  Starting with
  58. version 42.0 I became the new maintainer of the library.  I merged
  59. Leonard's version of the library into 42.0, the whole source distribution
  60. was cleaned up and reorganized and many bugs were fixed.  Also new
  61. functionality was added such as timezone support.
  62.  
  63. Thanks to Jeff Shepherd the support for network functions has been totally
  64. reorganized for version 43.0.  A new ixnet.library was introduced that
  65. contains all the network handling.  This new library supports both AS225
  66. and AmiTCP.  Furthermore, there is no longer any need to maintain two
  67. versions of an Internet client or daemon as ixnet.library will do the
  68. multiplexing for you.  The program itself is completely shielded from the
  69. actual networking package in use.  Also, should a new networking package
  70. appear for the Amiga, then it is relatively easy to add support for that
  71. package to ixnet.library.  All existing programs will automatically be able
  72. to work with the new package too.
  73.  
  74. Version 43.0 also introduced support for automatic stack extension
  75. (provided you compiled your program with the -mstackextend flag).  This
  76. support was done by Matthias Fleischer.
  77.  
  78. Last, but not least, I've added the ptrace() function, which was essential
  79. for porting the GNU debugger, GDB.  So it is now possible to use a decent
  80. debugger with gcc (and with the GNU C++, fortran and ADA compilers).
  81.  
  82. As you can see a lot of development on ixemul.library is going on right
  83. now.  New versions are released with only 1-3 months in between.  Version
  84. 43.1 is almost ready and contains many bug fixes and enhancements.  I've
  85. cleaned up most of the TODO list and added MultiUser File System support
  86. that was contributed by Mike Krings.  Also support for AFS (Ami-FileSafe)
  87. was added.
  88.  
  89. For version 44.0 I want to merge the latest NetBSD sources back into the
  90. library, with the ultimate goal of porting most NetBSD applications to the
  91. Amiga.  So you can expect more improvements this year.
  92.  
  93. USAGE
  94.  
  95. The Aminet distribution of ixemul consists of several archives:  one for
  96. each flavor (CPU/FPU combination) of the library, one for the timezone
  97. support, an archive for documentation, an archive for various utilities and
  98. an SDK archive, containing headers, libraries and C-objects that provide
  99. the startup code.  There is also an ixemul source archive.  If you don't
  100. mind recompiling everything, and if you have a decent ADE environment, then
  101. all you have to do is retrieve this archive, as all the other archives are
  102. generated from this source distribution.
  103.  
  104. Besides the library itself, there are also some utilities and other
  105. goodies.  First of all, there is a special trace version of the library.
  106. Together with the ixtrace tool it allows you to see which library functions
  107. are called by the program you want to debug.  If you compile the library
  108. yourself you will also get, as part of the compile process, a debug version
  109. of the library.  If you get an Enforcer hit in the library, and if you have
  110. SegTracker installed, then you can track down in which source and at which
  111. line the hit took place using the gccfindhit tool (available from Aminet
  112. and ADE) that is similar to the FindHit tool which is part of the Enforcer
  113. package.  I've used this with great success in the past.
  114.  
  115. Various settings that influence the behavior of the library can be set
  116. using the ixprefs utility.  A small tool ixrun allowing you to run AmigaDOS
  117. scripts from within the Unix shell is also provided.  An ixemul-specific
  118. pipe-handler allows you to set up a pipe between an AmigaDOS utility and an
  119. Unix program.  A pipe between two Unix programs is handled by the
  120. ixemul.library itself, but since AmigaDOS programs are not under the
  121. control of the library, this handler is used instead.
  122.  
  123. Finally, the tools zic (for manipulating the timezone databases) and
  124. ixtimezone are also part of ixemul.  The ixtimezone tool can be used to
  125. automatically adjust the Amiga time based on the currently selected
  126. timezone.  The best way to use this tool is to install the timezone
  127. databases (in etc:zoneinfo), set the TZ environment variable correctly (in
  128. my case "Europe/Amsterdam"), add the line "ixtimezone -patch-resource
  129. >nil:" to your user-startup and set the Amiga clock to Greenwich Mean Time
  130. (or Universal Time, as it is now called).  Now you will never have to worry
  131. about things like Daylight Saving Time as each time ixtimezone is called,
  132. this tool checks the current timezone and will patch the Amiga clock to the
  133. right time.  This tool is also very useful if you also run NetBSD or Linux,
  134. as these OSes expect that the internal Amiga clock adheres to GMT.
  135.  
  136. MEMORY REQUIREMENTS
  137.  
  138. The library itself needs about 140 Kb, but if you want to do some useful
  139. work, such as compiling programs, I advise at least 4 Mb.  More importantly
  140. is the stack size:  set it to at least 70 Kb.  Especially the GNU 'cp'
  141. command is hungry for stack.  For large compile jobs a bigger stack may be
  142. needed.  Fred Fish has reported that compiling some really big programs
  143. (e.g.  octave) requires 1 Mb of stack.  However, this is extreme.  Usually
  144. 70-100 Kb suffices.
  145.  
  146. The reason for these large stacks is that the Unix operating system
  147. automatically extends the stack if it is too small. Therefore some Unix
  148. programs aren't exactly conservative with their stack space.
  149.  
  150. PROGRAMMING WITH IXEMUL
  151.  
  152. There is really very little to do.  If you have a decent ADE setup with the
  153. necessary compilers and tools, and if you have installed the ixemul SDK,
  154. then you are ready to go.  There is no need to do anything special, the
  155. communication between your program and ixemul.library is handled by the
  156. startup code (the *crt0.o files in the /ade/lib directory) and the standard
  157. C library (libc.a, also in /ade/lib) which are automatically linked with
  158. your program.  Note that ixemul.library together with the compile tools
  159. also provides profiling support (compile and link with -pg), and
  160. base-relative and resident support (compile with -fbaserel or -resident).
  161. Compile and link with -g to add debug information so that you can debug
  162. your program with gdb.
  163.  
  164. If you start gdb with the -enforcer option, then the program you are
  165. debugging will automatically stop and drop into the debugger as soon as an
  166. Enforcer hit occurs.  This is obviously very useful.
  167.  
  168. The startup code will automatically expand the command-line for you (e.g.
  169. 'echo *' will expand to 'echo <filenames in current directory>'). If you
  170. want to disable this in your program, then you should add the line:
  171.  
  172.     int expand_cmd_line = 0;
  173.  
  174. to your source. This global variable will tell the system not to expand the
  175. command-line.
  176.  
  177. Code like you would on a Unix system, so DON'T USE any information
  178. private to the library!
  179.  
  180. PORTING UNIX PROGRAMS
  181.  
  182. Most programs compile out-of-the-box.  There are a few exceptions to this
  183. rule.  First of all, programs like linkers and the like that have to be
  184. able to read or write the standard Amiga hunk format obviously need a lot
  185. of work.
  186.  
  187. Secondly, there is no virtual memory support, and therefore no real fork()
  188. function.  In most cases the fork() function is only used to spawn a new
  189. program, and in such cases it is possible to replace fork() by vfork(),
  190. which is a light-weight fork() replacement that was originally created for
  191. Unix to reduce the overhead a real fork() introduced.
  192.  
  193. A vfork() doesn't create a copy of itself as fork() does, but uses the
  194. parent's code and data.  Since the child will quickly call execve() to
  195. spawn another program, this sharing of the code and data is no problem and
  196. saves a lot of time.
  197.  
  198. In some cases, such as a Unix shell (pdksh for example), you really want to
  199. be able to port a program that uses a fork() that cannot be replaced with
  200. vfork().  There is a way to do this, although it is a lot of work.  First
  201. of all, the program has to be compiled with -resident.  Now you replace the
  202. fork() by a vfork2() call, and in the child code you call ix_resident() to
  203. copy the original data hunk to a new location.  Next you have to copy all
  204. the parent's data structures to the child.  In other words, you have to
  205. copy the complete state of the parent process to the child process.  This
  206. can be a lot of work.  Finally, you call vfork_resume() which unblocks the
  207. parent so that you now have two processes running separately from each
  208. other.
  209.  
  210. It is important to realize that you should never exit() from the parent
  211. before all vfork()'ed children have died.  Since exiting from the parent
  212. causes the parents code and data segments to be deallocated, the child
  213. would find itself without code space to run on, and would probably cause a
  214. severe machine crash!
  215.  
  216. So always call at least `wait (0)' before returning from the parent.
  217.  
  218. For an example of how this works, see jobs.c from the pdksh source
  219. distribution.  It's a kind of poor-man's fork().
  220.  
  221. The third case I've come across that couldn't easily be ported were
  222. programs that dump their state to a new file.  Emacs does this, as does GNU
  223. Common Lisp.  The idea is that such a program will read lots of packages,
  224. and then dump itself to a new file.  That new file can in turn be executed,
  225. and you will no longer have to load all those packages.  All this assumes
  226. that when you load a program, all the code and data ends up at the same
  227. memory address.  Something that is true for Unix, but not for the Amiga due
  228. to the lack of virtual memory.
  229.  
  230. However, if someone wants to do a port of such a program, please contact me
  231. as I have developed a technique to implement this.  At least, I've made
  232. this work with a small test program.  I've tried to use it with GNU Common
  233. Lisp, but time constraints prevented me from developing this further.
  234.  
  235. The last problematic category I've seen is GNU Emacs.  This program assumes
  236. that all the data it allocates will always end up in a continuous memory
  237. block, and that the upper 8 bits of each memory address are always the
  238. same.  The Amiga, however, can have multiple memory blocks positioned at
  239. various places in memory.  While there is a GNU Emacs port, this port does
  240. assume this limitation and if you have an Amiga with many memory blocks (as
  241. I had) GNU Emacs may easily crash.  No easy solution exists.
  242.  
  243. AMIGA PROGRAMMING & IXEMUL
  244.  
  245. If you use Amiga specific resources like Windows and Screens from
  246. Intuition, make sure to add an atexit() handler to close those resources,
  247. if the user should decide to interrupt your program.  Before the program is
  248. left, the chain of registered atexit-handlers is called in exit().  So
  249. PLEASE NEVER EVER call _exit() if you have registered any custom atexit()
  250. handlers.  It is a bad habit anyway, but normally you may call _exit()
  251. without resource lossage (stdio won't flush its buffers, but that's about
  252. all).
  253.  
  254. Ixemul provides a new unique Amiga specific signal called SIGMSG.  If you
  255. set up a handler for this signal, then the default mapping from
  256. SIGBREAKB_CTRL_C into SIGINT will no longer occur, and your handler is
  257. called with the following arguments:  signal_handler(SIGMSG,
  258. new_exec_signal_mask).
  259.  
  260. In this case, you have to deal with Exec signals yourself, so don't forget
  261. to clear those signals that you want to receive notification about again
  262. later.  Thus if you'd want to handle SIGBREAKB_CTRL_C yourself, don't
  263. forget to
  264.  
  265.   SetSignal (0, SIGBREAKF_CTRL_C)
  266.  
  267. at the end of the handler, or you'll never get notification about that
  268. signal again.
  269.  
  270. Most of the original BSD signals are implemented.  I don't think SIGSTOP is
  271. currently implemented, although it would be relatively easy to add.  The
  272. mechanisms are already in place.
  273.  
  274.                       Hans Verkuil (hans@wyst.hobby.nl, May 12, 1996)
  275.  
  276. (Parts of this README are from the original README by Markus Wild).
  277.